package com.books.service.login_regis.impl;/*
 *@Auther Zhourui
 *@data 2021/9/26  20:39
 *@Email 1605576647@qq.com
 */

import com.books.mapper.login_regis.UserLoginMapper;
import com.books.model.entity.login_regis.UserLogin;
import com.books.service.login_regis.IUserLoginService;
import com.books.util.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserLoginServiceImpl implements IUserLoginService {

    @Autowired(required = false)
    private UserLoginMapper userLoginMapper;

    @Autowired(required = false)
    private UserLogin userLogin;

    @Override
    public UserLogin loginByUname(String uname) {
        userLogin=userLoginMapper.findByUsername(uname);
        return userLogin;
    }

    @Override
    public UserLogin loginByAccount(String account) {
        userLogin=userLoginMapper.findByAccount(account);
        return userLogin;
    }

    @Override
    public UserLogin loginByEmail(String email) {
        userLogin=userLoginMapper.findByEmail(email);
        return userLogin;
    }

    @Override
    public void updateUserLogin(String psw, String email, String account) {
        userLoginMapper.updateUserLogin (Md5Util.code(psw),email,account);
    }

    @Override
    public void updateUserPwd(String psw, String email) {
        userLoginMapper.updateUserPwd(Md5Util.code(psw),email);
    }
}
